<template>
  <div class="data-view">
    <div class="screen" ref="screen">
      <!-- 顶部标题 -->
      <div class="top">
        <TopView />
      </div>
      <!-- 底部图表 -->
      <div class="bottom">
        <!-- 左侧图表 -->
        <div class="left">
          <TouristView class="tourist" />
          <SexView class="sex" />
          <AgeView class="age" />
        </div>
        <!-- 中间图表 -->
        <div class="center">
          <MapView class="map" />
          <LineView class="line" />
        </div>
        <!-- 右侧图表 -->
        <div class="right">
          <RightTop class="top-box" />
          <RightCenter class="center-box" />
          <RightBottom class="bottom-box" />
        </div>
      </div>
    </div>

  </div>
</template>

<script setup>
import { ref,onMounted } from 'vue';
import TopView from './components/top/TopView.vue';
// 左侧组件
import TouristView from './components/left/TouristView.vue';
import SexView from './components/left/SexView.vue';
import AgeView from './components/left/AgeView.vue';
// 中间组件
import MapView from './components/center/MapView.vue';
import LineView from './components/center/LineView.vue';
// 右侧组件
import RightTop from "./components/right/RightTop.vue";
import RightCenter from "./components/right/RightCenter.vue";
import RightBottom from "./components/right/RightBottom.vue";



// 获取数据大屏盒子内容的DOM元素
const screen = ref(null);
onMounted(() => {
  // 监听屏幕大小变化
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
});
// 定义大屏缩放比例
function getScale(w = 1960, h = 1200) {
  const ww = window.innerWidth / w;  // 屏幕宽度/大屏宽度
  const wh = window.innerHeight / h;  // 屏幕高度/大屏高度
  return ww < wh ? ww : wh;
}
// 监听屏幕大小变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
}

</script>

<style scoped lang="less">
.data-view {
  background-image: url('./images/bg.png');
  background-size: cover;
  width: 100vw;
  height: 100vh;

  .screen {
    width: 1960px;
    height: 1190px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform-origin: left top;
    // background-color:antiquewhite;
    .top {
      width: 100%;
      height: 40px;
      // background-color: #12eddb;
    }
    .bottom {
      display: flex;
      .left {
        flex: 1;
        display: flex;
        flex-direction: column;
        .tourist {
          flex: 1;
        }
        .sex {
          flex: 1;
        }
        .age {
          flex: 1;
        }
      }
      .center {
        flex: 2;
        display: flex;
        flex-direction: column;
        .map {
          flex: 3.5;
          margin-top: 35px;
        }
        .line {
          flex: 1.5;
        }
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-left: 20px;
        .top-box {
          flex: 1;
        }
        .center-box {
          flex: 1;
        }
        .bottom-box {
          flex: 1;
        }
      }
    }
  }
}
</style>